<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	UserBean user = (UserBean)request.getSession().getAttribute("userBean");
	String _db = user.getDbType();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="<%=basePath%>">
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />
		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerForm.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerComboBox.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerDateEditor.js"></script>
		<script type="text/javascript" src="ligerUI/jquery-validation/jquery.validate.min.js"></script> 
    	<script type="text/javascript" src="ligerUI/jquery-validation/jquery.metadata.js"></script>
    	<script type="text/javascript" src="ligerUI/jquery-validation/messages_cn.js" ></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerResizable.js"></script>
<script type="text/javascript">
	var _db = '<%=_db%>';
	var _jsonObj2 = {};
	_jsonObj.classname = "com.wxtf.platform.main.contraceptives.TmaApplyAuditingMainAction";
	_jsonObj.methodname = "queryPage";
	_jsonObj2.classname = "com.wxtf.platform.main.contraceptives.TmaApplyAuditingDetailAction";
	_jsonObj2.methodname = "queryPage";
	var manager;//表格
	var warehousingdetail;//明细
	var mingxi = [];
	var tmaod = 0;
	$(function(){ 
	manager = $("#TmaApplyMain-grid").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height: '100%',enabledSort:false,
		usePager: true, rownumbers: true, checkbox: true, alternatingRow: true,async:false,
		columns: [
			{ display: 'tmaam_id', name: 'tmaam_id', hide: true,width:1 },
			{ display: 'org_id', name: 'org_id', hide: true,width:1 },
			{ display: '申领编号', name: 'tmaam_code', width: 180, align: 'center', render: function(record, index, value, oth){
					return "<a href='javascript:detail(" + JSON.stringify(record) + ")'>"+value+"</a>";
				}
			},
			{ display: '申领日期', name: 'tmaam_time', width: 100, align: 'center' },
			{ display: '审核部门', name: 'CAPTION2', width:  120, align: 'center' },
			{ display: '申领部门', name: 'CAPTION', width:  120, align: 'center' },
			{ display: '申领人', name: 'tmaam_person', width:  120, align: 'center' },
		
			{ display: '状态', name:'tmaam_status',width:100, align: 'center' ,render: function(record, index, value, oth){
					if(value=="0"){
						return "同意";
					}else if(value=="1"){
						 return "未提交";
					}else if(value=="2"){
						return "驳回";
					}else if(value=="3"){
						return "<font color=red>已冲红</font>";
					}else if(value=="4"){
						return "未审核";
					}
				}
			},
			{ display: '审批', name:'tmaam_status',width:60,render: function(record, index, value, oth){
					
					if(value!="4"){
						 return "<img src='ligerUI/skins/icons/search.gif'   onclick='editData(" + JSON.stringify(record) + ")'></img>";
					} else{
						 return "<img src='ligerUI/skins/icons/edit.gif' onclick='editData(" + JSON.stringify(record) + ")'></img>";
					}
				}
			}
		], 
		toolbar: {
			items: [
				 
			]
		}	
	});	
});
/*
 * 表格刷新
 */
function reload(){
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = "[]";
	_jsonObj2.methodname = "queryPage";
	_jsonObj2.logicdata = "[]";
	manager.loadData();
}
function tmad_name_change(value){
	//定义药具
	var paramId = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaApplyAuditingDetailAction",
		"methodname": "selectTmaDictionaryById",
		"logicdata": [],
		"extenddata": []
	};
	paramId.logicdata = '[{"tmad_id":"'+value+'"}]';
	callserver(paramId, function(data, satus){
		$("#tmad_price").val(data.tmad_price);
		$("#tmad_batch_code").val(data.tmad_batch_code);
		$("#tmad_qgp").val(data.tmad_qgp);
		$("#tmad_company_name").val(data.tmad_company_name);
		$("#tmad_unit").val(data.tmad_unit);
		$("#tmad_spec").val(data.tmad_spec);
		$("#tmad_description").val(data.tmad_description);
	},function(data, satus){
		warningTip(data.resultrecord);
	});
}
function tmgd_name_change(value){
	$("#tmad_name").find("option").remove();
	//定义药具名称
	var paramName = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaApplyAuditingDetailAction",
		"methodname": "selectTmaDictionary",
		"logicdata": [],
		"extenddata": []
	};
	paramName.logicdata = '[{"tmgd_id":"'+value+'"}]';
	callserver(paramName, function(data, satus){
		$("#tmad_price").val("");
		$("#tmad_batch_code").val("");
		$("#tmad_qgp").val("");
		$("#tmad_company_name").val("");
		$("#tmad_unit").val("");
		$("#tmad_spec").val("");
		$("#tmad_description").val("");
		$("#tmad_name").append('<option value="">--请选择--</option>');
		$.each(data, function (i, item) {
        	 $("#tmad_name").append('<option value="'+item.tmad_id+'">'+item.tmad_name+'</option>');
        }); 
	},function(data, satus){
		warningTip(data.resultrecord);
	});
}
/*
 * 药品增加
 */
var add_dialog;
function add(){
	document.getElementById('TmaApplyDetail-form').reset();
	$("#tmgd_name").find("option").remove();
	//定义药具类型
	var param = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaApplyAuditingDetailAction",
		"methodname": "selectTmGeneralDictionary",
		"logicdata": [],
		"extenddata": []
	};
	callserver(param, function(data, satus){
	$("#tmgd_name").append('<option value="">--请选择--</option>');
		$.each(data, function (i, item) {
        	 $("#tmgd_name").append('<option value="'+item.tmgd_id+'">'+item.tmgd_name+'</option>');
        });
	},function(data, satus){
		warningTip(data.resultrecord);
	});
	add_dialog = initWindowByDiv('TmaApplyDetailAdd-div', '明细增加', 600, 210, save, closeWin);
}
/*
*药品删除
*/
function del(){
	var str = "";
	//获取明细表格选中的复选框
    var rows = warehousingdetail.getCheckedRows();
    $(rows).each(function (){
    	str += this.tmaad_id + ",";
    });
    str=str.substring(0,str.length-1);
	if(str == ""){
		warningTip('请至少选则一个药品进行操作');
		return;
	}
	$.ligerDialog.confirm('确定要删除选中的数据吗？（删除不可恢复）', function (opt) { 			
		if(opt){ 
			var temp = mingxi;
	    	mingxi = [];
	    	$.each(temp, function (i, item) {
				if(str.indexOf(item.tmaad_id)>=0){
					
				}else{
					mingxi.push({
    					tmaad_id:item.tmaad_id,
    					tmad_id:item.tmad_id,
    					tmaid_num:item.tmaid_num
    				});
				}
	    	});
			warehousingdetail.deleteSelectedRow(); 
			_jsonObj2.methodname = "delete";
			_jsonObj2.logicdata = "[{\"ids\":\"" + str + "\"}]";
			callserver(_jsonObj2, function(){ reload(); }, function(){});
		}
	});
}
function detail(record){
	$("#d_tmaim_code").val(record.tmaam_code);
	$("#d_tmaim_time").val(record.tmaam_time);
	$("#d_org").val(record.org_id);
	$("#d_tmaam_person").val(record.tmaam_person);
	$("#d_CAPTION2").val(record.CAPTION2);
	$("#d_reserve1").val(record.reserve1);
	$("#d_tmaam_content").val(record.tmaam_content);
	//定义明细的参数
	var param = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaApplyAuditingDetailAction",
		"methodname": "queryPage",
		"logicdata": [],
		"extenddata": []
	};
	param.logicdata = "[{\"tmaam_id\":\""+record.tmaam_id+"\"}]"; 
	//明细
	$("#TmaApplyDetail").ligerGrid({
		url: _url, parms: param, width: '650', height:'200',enabledSort:false,
		usePager: true, rownumbers: true, alternatingRow: true,async:false,
		columns: [
			{ display: '药具种类', name: 'tmgd_name', width: 120, align: 'left' },
			{ display: '药品名称', name: 'tmad_name', width: 110, align: 'left' },			
			{ display: '生产厂家', name: 'tmad_company_name', width: 110, align: 'left' },
			{ display: '单价', name: 'tmad_price', width: 70, align: 'right' },
			{ display: '金额', name: 'tmad_qgp', width: 70, align: 'right' },
			{ display: '申请数', name: 'tmaad_num', width: 70, align: 'right' },
			{ display: '库存数', name: 'num', width: 60, align: 'right' }
		]
	});
	initWindowByDiv2('TmaApplyDetail-div', '药具申领单审批', 760, 430, closeWin);
}
/*
 * 药具申领单
 */
 var addData_dialog; 
function addData(){
	document.getElementById('TmaApplyMain-form').reset();
	addData_dialog = initWindowByDiv('TmaApplyMainAdd-div', '药具申领明细单', 760, 420, insert, closeWin);
	mingxi = [];
	tmaod = 0;
	//document.getElementById('a1').style.display = "none";
	//document.getElementById('a2').innerHTML = '<input type="button" onclick="baofeileixing();" value="报废类型" /><input type="hidden" id="CAPTION" name="CAPTION"/>';
	$("#tmaam_time").ligerDateEditor({ format: "yyyy-MM-dd", width:180});
	$("#tmaam_time").ligerGetDateEditorManager().setValue(getCurDateTime().substring(0,getCurDateTime().indexOf(" ")));
	//明细
	warehousingdetail = $("#TmaApplyDetail-grid").ligerGrid({
		url: _url, parms: param,
		width: '720', height:'290',enabledSort:false,
		usePager: true, rownumbers: true, checkbox: true, alternatingRow: true,async:false,
		columns: [
			{ display: 'tmaad_id', name: 'tmaad_id', hide: true,width:1 },
			{ display: 't_tmgd_name', name: 't_tmgd_name', hide: true,width:1 },
			{ display: 't_tmad_name', name: 't_tmad_name', hide: true,width:1 },
			{ display: '药具种类4', name: 'tmgd_name', width: 100, align: 'left' },
			{ display: '药品名称', name: 'tmad_name', width: 100, align: 'left' },			
			{ display: '生产厂家', name: 'tmad_company_name', width: 100, align: 'left' },
			{ display: '单价', name: 'tmad_price', width: 80, align: 'right' },
			{ display: '数量', name: 'tmaad_num', width: 80, align: 'right' },
			{ display: '金额', name: 'tmad_qgp', width: 80, align: 'right' },
			{ display: '修改', name:'edit',width:80,render: function(record, index, value, oth){
					return "<img src='ligerUI/skins/icons/edit.gif' onclick='edit(" + JSON.stringify(record) + ")'></img>";
				}
			}
		]
	});
	//var jsonObj = {};
    //jsonObj.Rows = [];
   // warehousingdetail.set({ data: jsonObj });
}

/*
 * 修改药具申领单
 */
 var addData_dialog; 
function editData(record){
 	if (record.tmaam_status!="4"  ){
 		detail(record);
 		return;
 	}
	document.getElementById('TmaApplyMain-form').reset();
	addData_dialog = initWindowByDiv('TmaApplyMainAdd-div', '药具申领明细单', 750, 430, update, closeWin);
	mingxi = [];
	tmaod = 0;
	$("#tmaam_time").ligerDateEditor({ format: "yyyy-MM-dd", width:180});
	$("#tmaam_time").ligerGetDateEditorManager().setValue(getCurDateTime().substring(0,getCurDateTime().indexOf(" ")));
	$("#tmaam_id").val(record.tmaam_id);
	$("#tmaam_code").val(record.tmaam_code);
	$("#tmaam_time").val(record.tmaam_time);
	$("#org_id").val(record.org_id);
	$("#tmaam_person").val(record.tmaam_person);
	$("#CAPTION2").val(record.CAPTION2);
	$("#tmaam_content").val(record.tmaam_content);
	$("#tmaam_memo").val(record.tmaam_memo);
	$("#tmaam_status").val(record.tmaam_status);
	$("#create_by").val(record.create_by);
	$("#create_time").val(record.create_time);
	$("#reserve1").val("<%=user.getUserrelName()%>");	
	//定义明细的参数
	var param = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaApplyAuditingDetailAction",
		"methodname": "queryPage",
		"logicdata": [],
		"extenddata": []
	};
	param.logicdata = "[{\"tmaam_id\":\""+record.tmaam_id+"\"}]";
	//加载药品种类选择框
	document.getElementById('TmaApplyDetail-form').reset();
	$("#tmgd_name").find("option").remove();
	//定义药具类型
	var param3 = {
		"classname": "com.wxtf.platform.main.contraceptives.TmaApplyAuditingDetailAction",
		"methodname": "selectTmGeneralDictionary",
		"logicdata": [],
		"extenddata": []
	};
	callserver(param3, function(data, satus){
	$("#tmgd_name").append('<option value="">--请选择--</option>');
		$.each(data, function (i, item) {
        	 $("#tmgd_name").append('<option value="'+item.tmgd_id+'">'+item.tmgd_name+'</option>');
        });
	},function(data, satus){
		warningTip(data.resultrecord);
	});
	
	//明细
	warehousingdetail = $("#TmaApplyDetail-grid").ligerGrid({
		url: _url, parms: param,
		width: '650', height:'220',enabledSort:false,
		usePager: true, rownumbers: true, checkbox: false, alternatingRow: true,async:false,
 		
		columns: [
			{ display: 'tmaad_id', name: 'tmaad_id', hide: true,width:1 },
			{ display: 't_tmgd_name', name: 't_tmgd_name', hide: true,width:1 },
			{ display: 't_tmad_name', name: 't_tmad_name', hide: true,width:1 }, 
			{ display: '药具种类', name: 'tmgd_name', width: 120, align: 'left' },
			{ display: '药品名称', name: 'tmad_name', width: 110, align: 'left' },	 
			{ display: '生产厂家', name: 'tmad_company_name', width: 110, align: 'left' },
			{ display: '单价', name: 'tmad_price', width: 70, align: 'right' },
			{ display: '申请数', name: 'tmaad_num', width: 70, align: 'right' },
			{ display: '库存数', name: 'num', width: 70, align: 'right' },
			{ display: '金额', name: 'tmad_qgp', width: 60, align: 'right' }

		] 
	});
    warehousingdetail.set({ data: param.data });
}

/*
 * 新建申领信息
 */
function insert(){
 
	var tmaam_content = $("#tmaam_content").val().trim(); 
	if('' == tmaam_content){warningTip("审核意见：不能为空"); return;}
	if(!checkIsString(tmaam_content)){
		warningTip("审核意见：必须为字母、数字、下划线、中文组成");
		return;
	} 
	if(fucCheckLength(tmaam_content) > 512){
		warningTip("审核意见：不能超过512字符");
		return;
	}
		//定义申领明细编号参数
		var param = {
			"classname": "com.wxtf.platform.main.contraceptives.TmaApplyAuditingMainAction",
			"methodname": "save",
			"logicdata": [],
			"extenddata": []
		};		
		var data = getForm("TmaApplyMain-form");
		var d = data.substring(0,data.length-2);
		d = d+",ids:"+JSON.stringify(mingxi)+"}]";
		param.logicdata = d;
		callserver(param, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
	 
	reload();
}

/*
 * 修改申领信息
 */
function update(){
	var tmaam_content = $("#tmaam_content").val().trim(); 
	if('' == tmaam_content){warningTip("审核意见：不能为空"); return;}
	if(!checkIsString(tmaam_content)){
		warningTip("审核意见：必须为字母、数字、下划线、中文组成");
		return;
	} 
	if(fucCheckLength(tmaam_content) > 512){
		warningTip("审核意见：不能超过512字符");
		return;
	}
		//定义申领明细编号参数
		var param = {
			"classname": "com.wxtf.platform.main.contraceptives.TmaApplyAuditingMainAction",
			"methodname": "update",
			"logicdata": [],
			"extenddata": []
		};		
		var data = getForm("TmaApplyMain-form");
		var d = data.substring(0,data.length-2);
		d = d+",ids:"+JSON.stringify(mingxi)+"}]";
		param.logicdata = d;
		callserver(param, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
 
		reload();
}

/*
 * 修改人员
 */
var edit_dialog;
function edit(r){
	document.getElementById('TmaApplyDetail-form').reset();
	tmgd_name_change(r.t_tmgd_name);
	row	= {
		tmaad_id:r.tmaad_id,
		tmgd_name:r.t_tmgd_name,
		tmad_name:r.t_tmad_name,				
		tmaad_num:r.tmaad_num,
		tmad_company_name:r.tmad_company_name,
		tmad_price:r.tmad_price,
		tmad_batch_code:r.tmad_batch_code,
		tmad_unit:r.tmad_unit,
		tmad_spec:r.tmad_spec,
		tmad_description:r.tmad_description,
		tmad_qgp:r.tmad_qgp
	};	
 
 
	loadForm("TmaApplyDetail-form", row);
	edit_dialog = initWindowByDiv('TmaApplyDetailAdd-div', '明细修改', 600, 210, bianji, closeWin);	
}
function bianji(){
	var tmaam_content = $("#tmaam_content").val().trim(); 
	if('' == tmaam_content){warningTip("审核意见：不能为空"); return;}
	if(!checkIsString(tmaam_content)){
		warningTip("审核意见：必须为字母、数字、下划线、中文组成");
		return;
	} 
	if(fucCheckLength(tmaam_content) > 512){
		warningTip("审核意见：不能超过512字符");
		return;
	}
		var d = getForm("TmaApplyDetail-form");
		//得到的JSON			
		var strJSON = d.substring(1,d.length-1);
		//转换后的JSON对象
		var obj = eval( "(" + strJSON + ")" );
		var jsonObj = {};
    	jsonObj.Rows = [];
		$.each(warehousingdetail.getData(), function (i, item) {
			if(obj.tmaad_id==item.tmaad_id){
				jsonObj.Rows.push({
        			tmaad_id:obj.tmaad_id,
					tmgd_name:$("#tmgd_name").find("option:selected").text(),
					tmad_name:$("#tmad_name").find("option:selected").text(),
					t_tmgd_name:obj.tmgd_name,
					t_tmad_name:obj.tmad_name,				
					tmaad_num:obj.tmaad_num,
					tmad_company_name:obj.tmad_company_name,
					tmad_price:obj.tmad_price,
					tmad_batch_code:obj.tmad_batch_code,
					tmad_unit:obj.tmad_unit,
					tmad_spec:obj.tmad_spec,
					tmad_description:obj.tmad_description,
					tmad_qgp:obj.tmad_qgp
        		});
			}else{
				jsonObj.Rows.push({
	        		tmaad_id:item.tmaad_id,
					tmgd_name:item.tmgd_name,
					tmad_name:item.tmad_name,
					t_tmgd_name:item.t_tmgd_name,
					t_tmad_name:item.t_tmad_name,				
					tmaad_num:item.tmaad_num,
					tmad_company_name:item.tmad_company_name,
					tmad_price:item.tmad_price,
					tmad_batch_code:item.tmad_batch_code,
					tmad_unit:item.tmad_unit,
					tmad_spec:item.tmad_spec,
					tmad_description:item.tmad_description,
					tmad_qgp:item.tmad_qgp
	        	});
			}
    	});
    	warehousingdetail.set({ data: jsonObj });
    	var temp = mingxi;
    	mingxi = [];
    	$.each(temp, function (i, item) {
			if(obj.tmaad_id==item.tmaad_id){
				mingxi.push({
		    		tmaad_id:obj.tmaad_id,
		    		tmad_id:obj.tmad_name,
		    		tmaad_num:obj.tmaad_num
		    	});
			}else{
				mingxi.push({
		    		tmaad_id:item.tmaad_id,
		    		tmad_id:item.tmad_id,
		    		tmaad_num:item.tmaad_num
		    	});
			}
    	});
		edit_dialog.hide();
 
}
/*
 * ajax成功回调
 */
function ajaxCallbackSuccFunc(data, textStatus){

	if(data.result || data.result == 'true'){
		succMsgTip(data.resultrecord);
	}else{
		warningTip(data.resultrecord);
	}  
	if(addData_dialog && data.result){
		addData_dialog.hide();
	}  
	reload(); 
}

/*
 * ajax失败回调
 */
function ajaxCallbackErrorFunc(data, textStatus){
	warningTip(data.resultrecord);
}

/*
 * 新建/修改申领信息
 */
function save(){
	tmaod++;
	var tmaam_content = $("#tmaam_content").val().trim(); 
	if('' == tmaam_content){warningTip("审核意见：不能为空"); return;}
	if(!checkIsString(tmaam_content)){
		warningTip("审核意见：必须为字母、数字、下划线、中文组成");
		return;
	} 
	if(fucCheckLength(tmaam_content) > 512){
		warningTip("审核意见：不能超过512字符");
		return;
	}
		var t = getForm("TmaApplyDetail-form");
		//得到的JSON			
		var strJSON = t.substring(1,t.length-1);
		//转换后的JSON对象
		var obj = eval( "(" + strJSON + ")" );
		var jsonObj = {};
    	jsonObj.Rows = [];
		$.each(warehousingdetail.getData(), function (i, item) {
			jsonObj.Rows.push({
        		tmaad_id:item.tmaad_id,
				tmgd_name:item.tmgd_name,
				tmad_name:item.tmad_name,
				t_tmgd_name:item.t_tmgd_name,
				t_tmad_name:item.t_tmad_name,				
				tmaad_num:item.tmaad_num,
				tmad_company_name:item.tmad_company_name,
				tmad_price:item.tmad_price,
				tmad_batch_code:item.tmad_batch_code,
				tmad_unit:item.tmad_unit,
				tmad_spec:item.tmad_spec,
				tmad_description:item.tmad_description,
				tmad_qgp:item.tmad_qgp
        	});
    	});
    	jsonObj.Rows.push({
			tmaad_id:tmaod,
			tmgd_name:$("#tmgd_name").find("option:selected").text(),
			tmad_name:$("#tmad_name").find("option:selected").text(),
			t_tmgd_name:obj.tmgd_name,
			t_tmad_name:obj.tmad_name,				
			tmaad_num:obj.tmaad_num,
			tmad_company_name:obj.tmad_company_name,
			tmad_price:obj.tmad_price,
			tmad_batch_code:obj.tmad_batch_code,
			tmad_unit:obj.tmad_unit,
			tmad_spec:obj.tmad_spec,
			tmad_description:obj.tmad_description,
			tmad_qgp:obj.tmad_qgp
		});
    	warehousingdetail.set({ data: jsonObj });
    	mingxi.push({
    		tmaad_id:tmaod,
    		tmad_id:obj.tmad_name,
    		tmaad_num:obj.tmaad_num
    	});
		add_dialog.hide();
	 
}
/*
 * 删除
 */
function delData(){
	var str = "";
	//获取表格以选中的复选框
    var rows = manager.getCheckedRows();
    $(rows).each(function (){
    	str += this.tmaam_id + ",";
    });
    str=str.substring(0,str.length-1);
	if(str == ""){
		warningTip('请至少选则一个申领单进行操作');
		return;
	}
	$.ligerDialog.confirm('确定要删除选中的数据吗？（删除不可恢复）', function (opt) { 			
		if(opt){
			_jsonObj.methodname = "delete";
			_jsonObj.logicdata = "[{\"ids\":\"" + str + "\"}]";
			callserver(_jsonObj, function(){ reload(); }, function(){});
		}
	});
}
/*
*报废类型
*/
function baofeileixing(){
	document.getElementById('a1').style.display = "block";
	document.getElementById('a2').innerHTML = '<div align="left"><select id="CAPTION" name="CAPTION" style=" width: 182px;"><option value="使用报废">使用报废</option><option value="库存报废">库存报废</option><option value="过期报废">过期报废</option></select></div>';	
}
</script>
</head>
	<body>
		<div id="TmaApplyMain-grid"></div>
		<div id="TmaApplyDetail-div" style="display: none;">				
				<table class="form_table">
					<tr> 
						<td class="form_label" style="width:110px">申领编号：</td>
						<td style="width:120px"><input disabled="disabled" class="textbg1" id="d_tmaim_code" name="d_tmaim_code"/></td>
						<td class="form_label" style="width:180px">申领日期：</td>
						<td style="width:280px"><input disabled="disabled" class="textbg1" id="d_tmaim_time" name="d_tmaim_time"/></td>
					</tr>
					<tr>
						<td class="form_label">组织机构：</td>
						<td><input disabled="disabled" class="textbg1" id="d_org" name="d_org"/></td>
						<td class="form_label">申请人：</td>
						<td><input disabled="disabled" class="textbg1" id="d_tmaam_person" name="d_tmaam_person"/></td>
					</tr>
					<tr>
						<td class="form_label">审核机构：</td>
						<td><input disabled="disabled" class="textbg1" id="d_CAPTION2" name="d_CAPTION2"/></td>
						<td class="form_label">审核人：</td>
						<td><input disabled="disabled" class="textbg1" id="d_reserve1" name="d_reserve1"/></td>
					</tr>
					<tr>
						<td class="form_label">审核意见：</td>
						<td colspan="3" align=left><textarea disabled="disabled" class="textbg4" id="d_tmaam_content" name="d_tmaam_content" validate="{maxlength:512}" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" style="height: 50px;width: 590px"></textarea></td>
					</tr>
					<tr>
						<td colspan="4" align=center><div id="TmaApplyDetail"></div></td>
					</tr>					
				</table>
		</div>
		<div id="TmaApplyMainAdd-div" style="display: none;">
			<form id="TmaApplyMain-form" name="TmaApplyMain-form">
			     <input type="hidden" id="tmaam_id" name="tmaam_id" value="0"/>
			     <input type="hidden" id="create_by" name="create_by" value=""/>
			     <input type="hidden" id="create_time" name="create_time" value=""/>
			     <input type="hidden" id="last_modify_by" name="last_modify_by" value=""/>
			     <input type="hidden" id="last_modify_time" name="last_modify_time" value=""/>
			     <input type="hidden" id="reserve2" name="reserve2" value=""/>
			     <input type="hidden" id="reserve3" name="reserve3" value=""/>
			     <input type="hidden" id="reserve4" name="reserve4" value=""/>
			     <input type="hidden" id="reserve5" name="reserve5" value=""/>
				<table class="form_table">
					<tr>
						<td class="form_label"  style="width:110px">申领编号：</td>
						<td style="width:130px"><input   class="textbg1" id="tmaam_code" name="tmaam_code"  disabled="disabled"/></td>
						<td class="form_label"  style="width:210px">申领日期：</td>
						<td style="width:220px"><input disabled="disabled" id="tmaam_time" name="tmaam_time"/></td>
					</tr>
					<tr>
						<td class="form_label">组织机构：</td>
						<td><input disabled="disabled" class="textbg1" id="org_id" name="org_id"/>
 
						</td> 
						<td class="form_label">申请人：</td>
						<td  align=left><input   class="textbg1" id="tmaam_person" name="tmaam_person"  disabled="disabled"/></td>
					</tr>
					
					<tr>
						<td class="form_label">是否同意：</td>
						<td>
							<select id="tmaam_status" name="tmaam_status" style=" width: 182px;">
								<option value="0">同意</option>
								<option value="2">撤回</option> 
							</select>
						 </td> 
						<td class="form_label">审核人：</td>
						<td  align=left><input   class="textbg1" id="reserve1" name="reserve1"/></td>
	 			</tr>
					<tr>
						<td class="form_label">审核意见：</td>
						<td colspan="3" align=left><textarea   class="textbg4" id="tmaam_content" name="tmaam_content" validate="{maxlength:512}" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'" style="height: 50px;width: 576px"></textarea></td>
					</tr>
					<tr>
						<td colspan="4" align=center><div id="TmaApplyDetail-grid"></div></td>
					</tr>					
				</table>
			</form>
		</div>
		<div id="TmaApplyDetailAdd-div" style="display: none;">
			<form id="TmaApplyDetail-form" name="TmaApplyDetail-form">
			<input type="hidden" id="tmaad_id" name="tmaad_id"/>
				<table class="form_table">
					<tr>
						<td class="form_label">药具类型：</td>
						<td>
						<select validate="{required:true}" style=" width: 182px;" id="tmgd_name" name="tmgd_name" onchange="tmgd_name_change(this.value);">
							<option value="">--请选择--</option>
						</select>
						</td>
						<td class="form_label">药品名称：</td>
						<td>
						<select validate="{required:true}" style=" width: 182px;" id="tmad_name" name="tmad_name" onchange="tmad_name_change(this.value);">
							<option value="">--请选择--</option>
						</select>
						</td>
					</tr>
					<tr>
						<td class="form_label">药品描述：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_description" name="tmad_description" value=""/></td>
						<td class="form_label">药品规格：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_spec" name="tmad_spec"  value=""/></td>
					</tr>
					<tr>
						<td class="form_label">药品单位：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_unit" name="tmad_unit" value=""/></td>
						<td class="form_label">生产厂商：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_company_name" name="tmad_company_name" value=""/></td>
					</tr>
					<tr>
						<td class="form_label">保质期：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_qgp" name="tmad_qgp" value=""/></td>
						<td class="form_label">批号：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_batch_code" name="tmad_batch_code" value=""/></td>
					</tr>
					<tr>
						<td class="form_label">价格：</td>
						<td><input readonly="readonly" class="textbg1" id="tmad_price" name="tmad_price" value=""/></td>
						<td class="form_label">数量：</td>
						<td><input validate="{required:true,maxlength:5,digits:'只能是数字'}" class="textbg1" id="tmaad_num" name="tmaad_num" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"/></td>
					</tr>					
				</table>
			</form>
		</div>
	</body>
</html>